package com.googlecode.sere.method

import com.googlecode.sere.http.{HttpRequest, EnclosedEntity}
import com.googlecode.sere.translation.{AcceptedTypes, MediaType}

abstract class EntityEnclosingMethod(
  uri: String,
  val entity: EnclosedEntity,
  acceptedTypes: AcceptedTypes)
  extends RestMethod(uri, acceptedTypes)

object EntityEnclosingMethod {
  def entityFromRequest(request: HttpRequest) = {
    val mediaType = request.contentType.getOrElse(MediaType("application", "octet-stream"))
    EnclosedEntity(mediaType, request.body)
  }
}
